package com.ruoyi.project.mysql.statement;

import com.ruoyi.project.mysql.connection.AbstractConnectionProxy;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class PreparedStatementProxy extends AbstractPreparedStatementProxy
        implements PreparedStatement {

    public PreparedStatementProxy(AbstractConnectionProxy connectionProxy,
                                  PreparedStatement preparedStatement, String targetSQL) throws SQLException {
        super(connectionProxy, preparedStatement, targetSQL);
    }


    @Override
    public ResultSet executeQuery() throws SQLException {
        return ExecuteTemplate.execute(this, (statement, args) -> statement.executeQuery());
    }

    @Override
    public int executeUpdate() throws SQLException {
        return ExecuteTemplate.execute(this, (statement, args) -> statement.executeUpdate());
    }

    @Override
    public boolean execute() throws SQLException {
        return ExecuteTemplate.execute(this, (statement, args) -> statement.execute());
    }
}
